from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
driver = webdriver.Edge()
driver.get('https://www.jiuxian.com/')
# 点击页面登录
driver.find_element(By.CLASS_NAME,'headerLogin').click()
# 强制等待
time.sleep(2)
# 点击输入账号
driver.find_element(By.ID,'userName').send_keys('15232008902')
# 隐式等待
driver.implicitly_wait(2)
# 输入密码
driver.find_element(By.ID,'password').send_keys('123456Aa')
time.sleep(15)
# 点击登录按钮
driver.find_element(By.NAME,'bi_Usuallogin').click()
# 警告
driver.find_element(By.XPATH,'/html/body/div/div[4]/div[2]/div[2]/a').click()
# 搜索
a=driver.find_element(By.CSS_SELECTOR,'.search-form')
a.send_keys('茅台')
# 打印两个属性值
print(a.get_attribute('id'))
print(a.get_attribute('class'))
# 键盘输入
a.send_keys(Keys.ENTER)
# 浏览器事件
driver.back()
driver.forward()
driver.refresh()
# 显示等待
a1=WebDriverWait(driver,20,0.5).until(EC.presence_of_element_located((By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')))
a1.click()
driver.switch_to.window(driver.window_handles[-1])
a2=driver.find_element(By.NAME,'detail_jiarugouwuche')
# 鼠标左键点击
ActionChains(driver).click(a2).perform()
driver.find_element(By.NAME,'detail_chakangouwuche').click()



time.sleep(10)
